package com.zmj.mobile.controller;
import com.zmj.framework.response.Result;
import com.zmj.mobile.dto.QuoteItemMainIdDTO;
import com.zmj.mobile.dto.QuoteItemMainInsertDTO;
import com.zmj.framework.base.controller.BaseController;
import com.zmj.framework.response.Result;
import com.zmj.mobile.entity.QuoteItemMainEntity;
import com.zmj.mobile.service.IQuoteItemMainService;
import com.zmj.mobile.vo.QuoteItemMainIdVO;
import com.zmj.mobile.vo.QuoteItemMainVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.validation.Valid;


/**
 * <p>
 * 采购询比价/定价主表 前端控制器
 * </p>
 *
 * @author lzy
 * @since 2024-02-01
 */
@RestController
@Api(tags = {"QuoteItem"})
@RequestMapping("/v1/api/quote/item")
public class QuoteItemController {

    @Resource
    private IQuoteItemMainService quoteItemMainService;

    @ApiOperation(value = "新增")
    @PostMapping("/insert")
    public Result<QuoteItemMainIdVO> insert(@RequestBody @Valid QuoteItemMainInsertDTO insertDTO) {
        return Result.success(quoteItemMainService.insert(insertDTO));
    }

    @ApiOperation(value = "查询单条")
    @PostMapping("/getById")
    public Result<QuoteItemMainVO> getById(@RequestBody @Valid QuoteItemMainIdDTO idDTO) {
        QuoteItemMainVO quoteItemMain = quoteItemMainService.getById(idDTO);
        return Result.success(quoteItemMain);
    }
    @Autowired
    private IQuoteItemMainService iQuoteItemMainService;

    @Operation(summary = "导入")
    @PostMapping("import")
    public Result<Object> importExcel(@RequestPart(value = "file") MultipartFile file,int sheet) {
        iQuoteItemMainService.importExcel(file,sheet);
        return Result.success();
    }

}
